<template>
	<view class="class-overview">
		<jhj-sort ref="sort" class="sort" :sortData="sortData" @click="sortDataContent"></jhj-sort>
		<view class="content">
			<you-scroll ref="scroll" :fetch="SetJopData">
				<view class="recruitment-item" slot-scope="{row,index}" @click="SetJopDetail(row,index)">
					<recruitment-list :item="row"></recruitment-list>
				</view>
			</you-scroll>
		</view>
	</view>
</template>
<script>
	import {
		setJobList,
	} from '@/static/js/api/jop.js';
	import request from '@/static/js/request.js'
	import RecruitmentList from "./components/RecruitmentListItem.vue"
	import youScroll from '@/components/uni-list-scroll/you-scroll'
	import JhjSort from '@/components/jhj-sort/jhj-sort.vue'
	var self ;
	export default {
		components: {
			RecruitmentList,
			youScroll,
			JhjSort
		},
		data() {
			return {
				sortData: [
					[{
						name: '全部',
						isCheck: true
					}, {
						name: '今日',
						isCheck: false
					}, {
						name: '近三天',
						isCheck: false
					}, {
						name: '近七天',
						isCheck: false
					}, {
						name: '近两周',
						isCheck: false
					}],
					[{
						name: '全部',
						isCheck: true
					}, {
						name: '招个人',
						isCheck: false
					}, {
						name: '招班组',
						isCheck: false
					}],
					[{
						name: '全部',
						isCheck: true
					}, {
						name: '工时',
						isCheck: false
					}, {
						name: '工程量',
						isCheck: false
					}, {
						name: '固定',
						isCheck: false
					}],
					[{
						name: '全部',
						isCheck: true
					}, {
						name: '企业招聘',
						isCheck: false
					}, {
						name: '个人招聘',
						isCheck: false
					}]
				],
				// selectName: "",
				timeData: "",
				recruitDate: "",
				recruitmentDate: "",
				settlementDate: "",
				searchKeyName: ""
			}
		},
		onLoad(option) {
			this.recruitmentDate = option.select;
			this.setSortList();
		},
		mounted() {
			self = this;
			let i2 = 0;
			self.sortData[1].forEach((item2, index2) => {
				if (self.recruitmentDate == item2.name) {
					i2 = index2
				} else {
					item2.isCheck = false;
				}
			})
			self.$refs.sort.changeData(1, i2);
			this.$refs.scroll.loadData();
			// this.SetJopData();
		},
		methods: {
			setSortList() {
				if (this.recruitmentDate == "全部分类") {
					this.recruitmentDate = this.recruitmentDate.slice(0, 2)
				}
				this.sortData[1].forEach((item, index) => {
					if (this.recruitmentDate == item.name) {
						item.isCheck = true;
					} else {
						item.isCheck = false;
					}
				})
			},
			sortDataContent(item, index, index2) {
				if (index == 0) {
					if (index2 == 0) {
						this.timeData = ""
					} else if (index2 == 1) {
						this.timeData = "1"
					} else if (index2 == 2) {
						this.timeData = "3"
					} else if (index2 == 3) {
						this.timeData = "7"
					} else if (index2 == 4) {
						this.timeData = "14"
					}
				} else if (index == 1) {
					if (index2 == 0) {
						this.recruitmentDate = ""
					} else if (index2 == 1) {
						this.recruitmentDate = "个人"
					} else if (index2 == 2) {
						this.recruitmentDate = "班组"
					}
				} else if (index == 2) {
					if (index2 == 0) {
						this.settlementDate = ""
					} else if (index2 == 1) {
						this.settlementDate = "工时"
					} else if (index2 == 2) {
						this.settlementDate = "工程量"
					} else if (index2 == 3) {
						this.settlementDate = "固定"
					}
				} else if (index == 3) {
					if (index2 == 0) {
						this.recruitDate = ""
					} else if (index2 == 1) {
						this.recruitDate = "企业招聘"
					} else if (index2 == 2) {
						this.recruitDate = "个人招聘"
					}
				}
				this.$refs.scroll.loadData();
			},
			SetJopData(pageIndex, pageSize) {
				return setJobList(pageIndex + 1, pageSize, self.searchKeyName, self.timeData, self.recruitmentDate.replace('招',''), self.settlementDate,
					self.recruitDate).then(res => {
					// console.log(this.timeData)
					return res.data;
				})

			},
			SetJopDetail(item, index) {
				// debugger
				uni.navigateTo({
					url: `/pages/home/job/SetJopDetail?id=${item.id}`
				})
			},
		},
	}
</script>

<style lang="less" scoped>
	.class-overview {
		height: 100vh;
		position: relative;
		overflow: hidden;


		.sort {
			background: #FFFFFF;
		}

		.content {
			height: calc(100vh - 500rpx);
			background: #F4F5F9;

			.recruitment-item {
				background: #FFFFFF;
				margin-bottom: 20rpx;
				padding-top: 32rpx;
				padding-bottom: 40rpx;
			}
		}
	}
</style>
